﻿
//自动义双击方法
function CustomDbClick() {
}
//自定义新增方法
var fnCustomAdd = function () {
    /*window.parent.parent.$("#tabs").tabs('close', '新增客户信息');
    var pagetitle = "新增客户信息";
    parent.parent.addTabs(pagetitle, '../Crm/Customer/ModifyCustomerOld.aspx?r=' + Math.random() + '&flag=0&entity=' + const_EditEntity + '&title=' + encodeURI(pagetitle));
    parent.parent.NeedRefreshPage = this;*/
}
//自定义修改方法
var fnCustomEdit = function () {
    window.parent.parent.$("#tabs").tabs('close', '修改客户信息');
    var recordID = myDataTable.getSelectedRows()[0];
    record = myDataTable.getRecord(recordID);
    var vid = record.getData(const_entityID);
    var pagetitle = "修改客户信息";
    parent.parent.addTabs(pagetitle, '../Crm/Customer/ModifyCustomerOld.aspx?r=' + Math.random() + '&flag=1&entity=CrmCustomerOld&id=' + vid + '&title=' + encodeURI(pagetitle));
    parent.parent.NeedRefreshPage = this;
}
//自定义删除方法
var fnCustomDeleteData = function () {
    YAHOO.example.container.dialog3.hide();
}

//转到公海
var fnMoveToPublic = function () {
    var recordID = myDataTable.getSelectedRows()[0];
    record = myDataTable.getRecord(recordID);
    var vid = record.getData(const_entityID);
    if (vid != "") {
        if (confirm("是否确定把该客户移到公海?")) {
            var Url = "../../Extend/AjaxData/CustomOperating.aspx?r=" + Math.random() + "&action=update&entity=CrmCustomerOld&json=&id=" + vid;
            YAHOO.util.Connect.asyncRequest('POST', Url, {
                success: function (res) {
                    try {
                        var str = res.responseText;
                        if (str == "1") {
                            alert("客户转到公海成功!");
                            ReLoadData();
                        }
                        else {
                            alert(str);
                        }
                    }
                    catch (e) {
                    }
                    finally {
                    }
                },
                failure: function (error) {
                    alert("数据错误：" + error.statusText);
                }
            }, null);
        }
    }
}
//废弃
var fnMoveToRubbish = function () {
    var recordID = myDataTable.getSelectedRows()[0];
    record = myDataTable.getRecord(recordID);
    var vid = record.getData(const_entityID);
    if (vid != "") {
        document.getElementById("EditUIWindow").src = "../../Crm/Customer/CustomerToRubbish.aspx?r=" + Math.random() + "&id=" + vid;
        YAHOO.example.container.dialog1.show();
    }
}
//格式化
var formatExplain = function (elCell, oRecord, oColumn, sData) {
    if (sData.length > 25) {
        elCell.innerHTML = sData.substring(0, 25) + "...";
    } else {
        elCell.innerHTML = sData;
    }
}
//启动
var fnRunCustomer = function () {
    var recordID = myDataTable.getSelectedRows()[0];
    record = myDataTable.getRecord(recordID);
    var vid = record.getData(const_entityID);
    if (vid != "") {
        if (confirm("是否确定启动?")) {
            var Url = "../../Extend/AjaxData/CustomOperating.aspx?r=" + Math.random() + "&action=update&entity=ToCrmCustomerOld&json=&id=" + vid;
            YAHOO.util.Connect.asyncRequest('POST', Url, {
                success: function (res) {
                    try {
                        var str = res.responseText;
                        if (str == "1") {
                            alert("客户启动成功!");
                            ReLoadData();
                        }
                        else {
                            alert(str);
                        }
                    }
                    catch (e) {
                    }
                    finally {
                    }
                },
                failure: function (error) {
                    alert("数据错误：" + error.statusText);
                }
            }, null);
        }
    }
}